<!-- app/templates/meetings.html -->
{% extends "base.html" %}

{% block content %}

<!-- 顶部标题与返回按钮（风格与学习资料页保持一致） -->
<div class="d-flex justify-content-between align-items-center mb-4">
    <div>
        <a class="btn btn-outline-secondary btn-sm me-2" href="{{ request.headers.get('Referer','/') }}">← 返回首页</a>
        <h1 class="h3 mb-0 d-inline">组会记录详情</h1>
    </div>
    <div>
        <a class="btn btn-success" href="/meetings/new">+ 新建记录</a>
    </div>
</div>

<div id="meetings-list">
{% if meetings %}
    <div class="row">
    {% for m in meetings %}
        <div class="col-12 col-md-6 mb-3">
            <div class="card card-pretty h-100">
                <div class="card-body d-flex flex-column">
                    <div>
                        <!-- 不在首页直接展示详细内容，标题为纯文本 -->
                        <h5 class="card-title">{{ m.title }}</h5>
                        <p class="text-muted mb-1">作者: {{ m.author.username if m.author else '未知' }} • {{ (m.meeting_time or m.created_at.strftime('%Y-%m-%d')) }}</p>
                    </div>
                    <div class="mt-auto d-flex justify-content-between align-items-center">
                        <small class="text-muted">ID: {{ m.id }}</small>
                        <div class="d-flex gap-2">
                            <a class="btn btn-sm btn-primary" href="/meetings/{{ m.id }}">查看记录</a>
                            {% if user.is_admin or m.created_by == user.id %}
                                <form method="post" action="/meetings/{{ m.id }}/delete" style="display:inline;">
                                    <button class="btn btn-sm btn-outline-danger" type="submit" onclick="return confirm('确定删除该记录？')">删除</button>
                                </form>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endfor %}
    </div>
    </div>
{% else %}
    <div class="alert alert-info">暂无组会记录。</div>
{% endif %}
{% endblock %}
